package com.roc.web.action.bankcard;


import java.util.ArrayList;
import java.util.List;
import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

public class BankCardFourKeySearchCondition extends BaseSearchCondition{
	
	private static final long serialVersionUID = 1L;
	private String phoneNo;//手机号
	private String accountNo;//卡号
	private String identityCard;//身份证号
	private String accountName;//姓名
	private String minDate;
	private String maxDate;
	
	public String getPhoneNo() {
		return phoneNo;
	}

	public void setPhoneNo(String phoneNo) {
		this.phoneNo = phoneNo;
	}

	public String getAccountNo() {
		return accountNo;
	}

	public void setAccountNo(String accountNo) {
		this.accountNo = accountNo;
	}

	public String getIdentityCard() {
		return identityCard;
	}

	public void setIdentityCard(String identityCard) {
		this.identityCard = identityCard;
	}

	public String getAccountName() {
		return accountName;
	}

	public void setAccountName(String accountName) {
		this.accountName = accountName;
	}
	
	public String getMinDate() {
		return minDate;
	}

	public void setMinDate(String minDate) {
		this.minDate = minDate;
	}

	public String getMaxDate() {
		return maxDate;
	}

	public void setMaxDate(String maxDate) {
		this.maxDate = maxDate;
	}

	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
		if(Constance.isNotEmpty(phoneNo)){
			filedBeanList.add(new WhereHQLFieldBean("t.phone_no", phoneNo,"=", false));
		}
		if(Constance.isNotEmpty(accountNo)){
			filedBeanList.add(new WhereHQLFieldBean("t.account_no", accountNo,"=", false));
		}
		if(Constance.isNotEmpty(identityCard)){
			filedBeanList.add(new WhereHQLFieldBean("t.identity_card", identityCard,"=", false));
		}
		if(Constance.isNotEmpty(accountName)){	
			filedBeanList.add(new WhereHQLFieldBean("t.account_name",accountName, "=", false));
		}
		if(Constance.isNotEmpty(minDate) && Constance.isNotEmpty(maxDate)) {
			filedBeanList.add(new WhereHQLFieldBean("to_char(t.create_time, 'yyyy-MM-dd')", minDate, ">=", false));
			filedBeanList.add(new WhereHQLFieldBean("to_char(t.create_time, 'yyyy-MM-dd')", maxDate, "<=", false));
		}
		return filedBeanList;
	}

	@Override
	protected String getRowCountHQL() {
		StringBuffer sb=new StringBuffer();
		sb.append(" select count(1) from t_wechat_validate t where 1=1");
		return sb.toString();
	}

	@Override
	protected String getSearchHQL() {
		StringBuffer sb=new StringBuffer();
		sb.append(" select t.phone_no,t.account_no,t.account_name,t.identity_card,to_char(t.create_time,'yyyy-MM-dd') create_time from t_wechat_validate t where 1=1 ");
		return sb.toString();
	}

	@Override
	protected String getOrderPartOfHQL() {
		return "  order by t.create_time desc ";
	}
	
	

}
